home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / gamesmaster / source / e / sprites / sprites.e next >
Encoding:
Text File  |  1996-09-08  |  2.8 KB  |  84 lines

  1. /* Sprite example
  2. ** --------------
  3. ** This example shows you how to set up a 16 colour OCS sprite with a
  4. ** doubled X axis (32 pixels width).  Those with hardware experience will
  5. ** know that it takes 4 sprite banks to do this successfully in OCS, which
  6. ** leaves you with another 4 banks to do with what you will.  You can do
  7. ** this same demo in AGA with just 2 banks used.
  8. ** 
  9. ** The sprite is attached to the mouse, so try moving it around a bit.
  10. */
  11.  
  12. MODULE 'games','games/games','exec/memory'
  13.  
  14. PROC main()
  15.    DEF screen:PTR TO gamescreen, palette:PTR TO INT, sparkie:PTR TO sprite,
  16.        zbxy:LONG, timer:LONG
  17.  
  18.    palette := [    $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,
  19.         $0000,$0688,$0466,$0344,$0CC0,$0980,$0870,$0650,
  20.         $01C2,$0050,$0B0B,$0606,$0F20,$0910,$0BBB,$0FFF,
  21.         $00BF,$0068,$0568,$09BF,$0FF0,$0EE0,$0BA0,$0540
  22.           ]:INT;
  23.  
  24.    screen  := [    GSV1,0,              -> GameScreen Version 
  25.         0,0,0,               -> Screen_Mem1,2,3 
  26.         0,                   -> ScreenLink 
  27.         palette,             -> Address of Palette 
  28.         0,                   -> Address of RasterList 
  29.         32,                  -> Amount of colours in palette
  30.         320,256,             -> Screen Height, Width, Width/8 
  31.         320,256,             -> Pic Height, Width, Width/8 
  32.         1,                   -> Amt_Planes 
  33.         0,0,                 -> Top Of Screen, X/Y 
  34.         0,0,                 -> X/Y pic offsets 
  35.         SPRITES OR NOSPRBDR, -> Special attributes 
  36.         LORES,               -> Screen mode 
  37.         INTERLEAVED,         -> Screen type 
  38.         0,                   -> Screen Is Being Displayed? 
  39.         0                    -> Reserved
  40.           ]:gamescreen;
  41.  
  42.    sparkie := [    SPV1,0,         -> Version number
  43.         0,              -> Bank Number 0
  44.         0,              -> Ptr to graphic
  45.         100,100,        -> Beginning X/Y positions
  46.         0,              -> Current frame
  47.         16,21,          -> Width, Height
  48.         16,             -> Amt of colours
  49.         16,             -> Colour start in palette
  50.         2,              -> Amt of planes
  51.         HIRES OR XLONG, -> Resolution attributes
  52.         0,              -> Position in relation to playfields
  53.         0,0             -> Private
  54.           ]:sprite;
  55.  
  56.  
  57.    IF gmsbase := OpenLibrary('games.library',0)
  58.       SetUserPri()
  59.       IF (Add_Screen(screen) = ERR_OK)
  60.          sparkie.data := SmartLoad('GAMESLIB:data/sparkie.raw',0,0,MEMF_CHIP)
  61.      Init_Sprite(screen,sparkie)
  62.      Update_Sprite(screen,sparkie)
  63.      Show_Screen(screen)
  64.      zbxy := Read_Mouse(JPORT1)
  65.  
  66.      REPEAT
  67.        IF (timer++ AND $1)
  68.           IF (sparkie.frame = 5) THEN sparkie.frame := 0 ELSE sparkie.frame := sparkie.frame+1
  69.        ENDIF
  70.        zbxy := Read_Mouse(JPORT1)
  71.        sparkie.xpos := sparkie.xpos+getZBXYx(zbxy)
  72.        sparkie.ypos := sparkie.ypos+getZBXYy(zbxy)
  73.        Wait_OSVBL()
  74.        Update_Sprite(screen,sparkie)
  75.      UNTIL !(zbxy AND MB_LMB)
  76.  
  77.      FreeMemBlock(sparkie.data);
  78.      Delete_Screen(screen)        
  79.       ENDIF
  80.    CloseLibrary(gmsbase)
  81.    ENDIF
  82. ENDPROC
  83.  
  84.